#!/usr/bin/env python
# encoding: utf-8

if __name__ == '__main__':
    import pymssql

    # 连接数据库
    conn = pymssql.connect(server='192.168.7.140', user='sa', password='Saas_jy140',
                           database='tenant_JY972113')
    cursor = conn.cursor()

    # 查询表的元数据
   # table_name = 'your_table_name'  # 替换为你的表名
    query = "select username from sys_user;"
    cursor.execute(query)

    # 获取全部字段名列表
    columns = [row[0] for row in cursor.fetchall()]
    print(columns)

    # 关闭连接
    cursor.close()
    conn.close()